using System.Configuration;

namespace Microsoft.ConnectionEngine.SampleDeploymentManager.Configuration
{
    internal class ConfigurationManager : ConfigurationSection
    {
        #region Public properties
        public static string CancelPageName
        {
            get
            {
                ConfigurationManager configurationManager = (ConfigurationManager)System.Configuration.ConfigurationManager.GetSection("wizardSettings");

                if (configurationManager == null)
                {
                    return "";
                }

                return configurationManager._cancelPageName;
            }
            set
            {
                ConfigurationManager configurationManager = (ConfigurationManager)System.Configuration.ConfigurationManager.GetSection("wizardSettings");

                if (configurationManager != null)
                {
                    configurationManager._cancelPageName = value;
                }
            }
        }

        public static WizardPageConfigCollection WizardPages
        {
            get
            {
                ConfigurationManager configurationManager = (ConfigurationManager)System.Configuration.ConfigurationManager.GetSection("wizardSettings");

                if (configurationManager == null)
                {
                    return null;
                }

                return configurationManager._wizardPages;
            }
        }
        #endregion

        #region Private properties
        [ConfigurationProperty("cancelPageName", IsRequired = true, IsKey = false)]
        private string _cancelPageName
        {
            get
            {
                return this["cancelPageName"].ToString();
            }
            set
            {
                this["cancelPageName"] = value;
            }
        }

        [ConfigurationProperty("wizardPages", IsDefaultCollection = false, IsRequired = false)]
        private WizardPageConfigCollection _wizardPages
        {
            get
            {
                return (WizardPageConfigCollection)this["wizardPages"];
            }
        }
        #endregion
    }
}
